package com.example.chatroom.api;

import com.example.chatroom.model.Friend;
import com.example.chatroom.model.FriendMapper;
import com.example.chatroom.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.SessionAttribute;

import java.util.List;

@RestController
public class FriendAPI {
    @Autowired
    private FriendMapper friendMapper;

    @GetMapping("/friendList")
    public List<Friend> getFriendList(@SessionAttribute("user") User user) {
       return friendMapper.selectFriendList(user.getUserId());
    }
}
